home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc2 / iffmst16.lha / IFFMaster / rexx / IFFMaster.dopus < prev    next >
Text File  |  1996-05-04  |  4KB  |  186 lines

  1. /*
  2. **  $VER: IFFMaster.dopus 0.001 (12 Feb 1996)  **
  3. **
  4. **        © 1996 Andreas Mixich
  5. **
  6. **  PROGRAMNAME:
  7. **      IFFMaster.dopus
  8. **
  9. **  FUNCTION:
  10. **      This one is quite useless. ;-) It will replace IFFMasters main-window
  11. **      by displaying the contents of the whole file in an interactive DOPUS
  12. **      lister. You may then click on an entry to display it with IFFMaster's
  13. **      Info-window.
  14. **
  15. **
  16. **  $HISTORY:
  17. **
  18. **   12 Feb 1996 : 0.01 : initial release
  19. */
  20.  
  21. /* enable support functions */
  22.  
  23. OPTIONS RESULTS
  24. SIGNAL ON ERROR
  25. SIGNAL ON FAILURE
  26. SIGNAL ON HALT
  27. SIGNAL ON BREAK_C
  28. SIGNAL ON SYNTAX
  29.  
  30. /* add the needed libraries */
  31.  
  32. IF ~SHOW('LIBRARIES','rexxsupport.library') THEN
  33.      CALL ADDLIB('rexxsupport.library',0,-30,0)
  34.  
  35. /* define some usefull vars */
  36. LF         = '0A'x                  /* linefeed */
  37. scriptname = 'IFFMaster.dopus'      /* insert scriptname. will be needed later */
  38. iffport    = 'IFFMASTER.1'          /* Name of port for IFFMaster */
  39. dopusport  = 'DOPUS.1'              /* name of Dopus port */
  40. iffmastercommand = 'GFX:Tools/IFFMaster'    /* set to where you keep IFFMaster */
  41.  
  42. PARSE ARG file       /* what file to operate upon */
  43.  
  44. ADDRESS Value iffport
  45.  
  46. IF ~SHOW('Ports',iffport) THEN
  47.     DO
  48.     ADDRESS COMMAND 'Run >NIL: '||iffmastercommand
  49.     ADDRESS COMMAND 'WaitForPort '||iffport
  50.     IF ~SHOW('Ports',iffport) THEN
  51.         EXIT 10
  52. END
  53.  
  54. 'MAINWINDOW OFF'            /* not needed now */
  55. 'LOAD '||file               /* load file into IFFMaster */
  56. 'ENTRIES'                   /* how many entries are in the IFF file ? */
  57. num = RESULT                /* first one is 0 ! */
  58. 'CURSORPOS 0'               /* goto first position entry */
  59.  
  60. DO i = 1 TO num
  61.     'CHUNKID'
  62.     id = RESULT
  63.     'CHUNKTYPE'
  64.     type = RESULT
  65.     'CHUNKDEPTH'
  66.     depth = RESULT
  67.     IF depth = "RESULT" THEN
  68.     depth = ''
  69.     'CHUNKINFO'
  70.     info = RESULT
  71.     'CHUNKSIZE'
  72.     size = RESULT
  73.     entry.i = id||' '||type||' '||depth||' '||info||' '||size
  74.     IF i ~= num THEN
  75.     'CURSORPOS' i
  76. END
  77.  
  78.  
  79. ADDRESS Value dopusport     /* talk to DOPUS now */
  80.  
  81. 'STATUS 3'
  82. win = RESULT
  83.  
  84. 'STATUS 13' win
  85. path = RESULT
  86.  
  87. 'CLEARWIN'
  88. 'SETWINTITLE '||file
  89.  
  90. 'ADDCUSTHANDLER IFFDOPUS'   /* we will simulate the GUI in DOPIS' lister */
  91. 'ADDCUSTENTRY "Click here to get back." 0 2 3 1 '   /* so we can get back upon request */
  92.  
  93. DO i = 1 TO num
  94.     'ADDCUSTENTRY "'||entry.i||'" 0 1 0 1 0'    /* add entry No. i */
  95. END
  96.  
  97. 'DISPLAYDIR'
  98.  
  99. /* open our message port */
  100.  
  101. ourport = OpenPort('IFFDOPUS')
  102.  
  103. handlerstatus = 'OPEN'
  104.  
  105. DO UNTIL handlerstatus = 'CLOSE'
  106.     CALL WaitPkt(IFFDOPUS)
  107.     Packet = GetPkt(IFFDOPUS)
  108.     IF Packet ~= null() THEN
  109.     DO
  110.         Cmd = GetArg(Packet, 0)
  111.         IF Cmd = '1' | Cmd = '2' THEN
  112.         DO
  113.             Arg1 = GetArg(Packet, 1) /* entry number */
  114.             Arg2 = GetArg(Packet, 2) /* entry text   */
  115.             Arg3 = GetArg(Packet, 3) /* userdata     */
  116.             CALL Reply(Packet, 0)
  117.             ADDRESS VALUE dopusport
  118.             'Busy on'
  119.             IF Cmd = '1' THEN
  120.             DO
  121.                 IF Arg1 = 0 THEN
  122.                 handlerstatus = 'CLOSE'
  123.                 ELSE
  124.                 CALL showchunk(Arg1)
  125.             END
  126.             ELSE
  127.             NOP
  128.             'Busy off'
  129.         END
  130.         ELSE
  131.         CALL Reply(Packet, 0)
  132.  
  133.         IF Cmd = 'CLOSE' THEN
  134.             handlerstatus = 'CLOSE'
  135.     END
  136. END
  137.  
  138. /* close up the port */
  139.  
  140. 'STATUS 13 SET 'path win
  141. CALL ClosePort(ourport)
  142.  
  143. EXIT(0)
  144.  
  145. /* what to do if user double clicked on chunk */
  146. showchunk:
  147. PARSE ARG arg1
  148.  
  149.   ADDRESS Value iffport
  150.   'CURSORPOS' arg1-1
  151.   'INFOWINDOW ON'
  152.  
  153. RETURN(0)
  154.  
  155. /* universal requester function */
  156. DREQUEST:
  157. PARSE VAR ErrText, RtValue
  158.  
  159. ADDRESS DOPUS.1
  160. REQUEST scriptname||'0a'x||ErrText||'0a'x||RtValue
  161.  
  162. RETURN RtValue
  163.  
  164. /* what to do on BREAK_C or on HALT */
  165. BREAK_C:
  166. HALT:
  167.   Err1 = 'Script interrupted'
  168.   Err2 = 'Execution Ceased at line - 'SIGL
  169.   Err3 = 'Source Line: 'SourceLine(SIGL)
  170.   ErrText = Err1'*n'Err2'*n'Err3
  171.   CALL DRequest(ErrText,10)
  172.   EXIT(RtValue)
  173. RETURN
  174.  
  175. /* routine for an error */
  176. ERROR:
  177. SYNTAX:
  178. FAILURE:
  179.   Err1 = 'Trapped Error: 'ErrorText(rc)
  180.   Err2 = 'Line 'SIGL':'SourceLine(SIGL)
  181.   ErrText = Err1'*n'Err2
  182.   CALL DRequest(ErrText,20)
  183.   EXIT(RtValue)
  184. RETURN
  185.  
  186.